<% @main_header = "Ptrack : The Ultimate Project Tracker" %>
<div id="latest_user" class='span-10 colborder' >
  <table>
    <tr>
      <td>
        <h3>Latest Activities:</h3>
        <ul>
          <% for active_project in @active_projects %>
            <%  if active_project.activities.length>0 %>
              <li><strong><%= active_project.name %></strong></li>
              <ul><%  for activity in active_project.activities %>
                  <% if activity.tasks.length > 0 %>
                    <li><%= Phase.find(activity.phase_id).name %></li>
                    <ul><%  for task in activity.tasks %>
                        <% if Workunit.find(:all,:conditions => "task_id = #{task.id.to_s}" ).length>0 %>
                          <li><%= link_to(task.name, project_task_url(active_project.id,task)) %></li>
                          <ul><% for workunit in Workunit.find(:all,:limit =>3,:order=>"created_at DESC",:conditions => "task_id = #{task.id.to_s}" ) %>
                              <li><%= User.find(workunit.user_id).login + " worked for " +
                                workunit.amount.to_s + " hrs, on #{workunit.worked_at.strftime('%d/%m/%Y')}" %></li>
                            <% end %></ul><% end %>
                        <% end %></ul><% end %>
                    <% end  %>
              </ul><%  end %>
          <% end %>
        </ul>
      </td>
    </tr>
  </table>
</div>

<div id="info" class='span-13 last'>
  <h3><%= link_to 'Create New Project', :action => 'new' %></h3>
  <div id="active-projects">
    <h3>Active Projects:</h3>
    <% unless @active_projects.empty? %>
      <ul>
        <% @active_projects.each do |project| %>
          <li>
            <%= link_to(project.name, project) %>&nbsp;&nbsp;<%= link_to image_tag("/images/application_edit.png") +" Edit",edit_project_url(project.id)%>
          </li>
        <% end %>
      </ul>
    <% else %>
      No active project found! Don't you work?
    <% end %>
  </div>
  <div id="archived-projects">
    
  </div>
</div>
